import com.mosesSupposes.fuse.*;
class com.Lithyem.NSGS.Profiles.TextScreens extends MovieClip{
	
	var holder_mc:MovieClip;
	
	var textBlocks:Array;
	
	var index:Number;
	
	var oldScreen:MovieClip;
	var newScreen:MovieClip;
	
	var Controller:Object;
	
	function TextScreens(){
		var textBlocks:Array;
	}
	
	
	function init(d:Array,c:Number, ctl:Object):Void{
		
		Controller = ctl;
		
		var c_obj = new Color(this);
		c_obj.setRGB(c);
	
		
		for(var i = 0; i < d.length; i++){
			if(d[i].title || d[i].name){
				var ts = holder_mc.attachMovie('TextScreenInit','ts_'+i,i);
			}else{
				var ts = holder_mc.attachMovie('TextScreen','ts_'+i,i);
			}
			
			ts._x = -200;
			_global.setTimeout(this,'initBlock',200,[d[i],ts]);
		}
	}
	
	function initBlock(d:Object):Void{
		if(d[0].title || d[0].name){

			d[1].name_txt.text = d[0].name;
			d[1].title_txt.text = d[0].title;
			d[1].subtitle_txt.text = d[0].subtitle;
		}else{
			d[1].text_txt.text = d[0].copy;
		}
		
	
	}
	
	function reset():Void{
		// if prev screen exists, remove it
		if(oldScreen){
			slideOut(oldScreen);
		}
		
		if(newScreen){
			slideOut(newScreen);
		}
		
		index = -1;
	}
	
	function slideOut(who:MovieClip):Void{
		// slide out clip.
		
		var f = new Fuse(
			{target:who, x:-200, seconds:.3, ease:'easeInOutQuad'}
		);
		f.start();
		
		
		
	}
	
	function slideIn(who:MovieClip,delay:Number){
		// fuseslide in, delay to accomodate slideout
		var f = new Fuse(
			{target:who, x:0, seconds:.7, ease:'easeInOutQuad', delay:.7}
		);
		f.start();
	}
	
	function showScreenByIndex(i:Number):Void{
		if(i == index){
			return;
		}else{
			index = i;
		}
		
		oldScreen = newScreen;
		
		newScreen = holder_mc['ts_'+i];
		
		if(oldScreen){
			slideOut(oldScreen);
		}
		
		slideIn(newScreen,.5);
	}
	
}